package com.yunhe.common.model.data;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yunhe.common.util.StringUtil;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

public class RunStrategy {

    private Long id;
    private Long firmCode;
    private Long stationCode;
    private String strategyName;
    private String runMonth;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
    private Long statusCode;
    private List<RunStrategyDetail> runStrategyDetails;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getFirmCode() {
        return firmCode;
    }

    public void setFirmCode(Long firmCode) {
        this.firmCode = firmCode;
    }

    public Long getStationCode() {
        return stationCode;
    }

    public void setStationCode(Long stationCode) {
        this.stationCode = stationCode;
    }

    public String getStrategyName() {
        return strategyName;
    }

    public void setStrategyName(String strategyName) {
        this.strategyName = strategyName;
    }

    public String getRunMonth() {
        return runMonth;
    }

    public void setRunMonth(String runMonth) {
        String[] split = runMonth.split(",");
        List<Integer> list = new ArrayList<>();
        for (String s : split) {
            if (StringUtil.isNumber(s)) {
                list.add(Integer.parseInt(s));
            }
        }
        Collections.sort(list);
        StringBuffer buffer = new StringBuffer();
        for (Integer integer : list) {
            buffer.append(integer).append(",");
        }
        String string = buffer.toString();
        this.runMonth = string.substring(0, string.length() - 1);
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Long getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Long statusCode) {
        this.statusCode = statusCode;
    }

    public List<RunStrategyDetail> getRunStrategyDetails() {
        return runStrategyDetails;
    }

    public void setRunStrategyDetails(List<RunStrategyDetail> runStrategyDetails) {
        this.runStrategyDetails = runStrategyDetails;
    }
}
